using System;

namespace lucere.io.concurrency
{
	public abstract class LockFactory : ILockFactory
	{
		protected string _lockPrefix;

		///<summary>
		///Get or Set the prefix in use for all locks created in this
		///LockFactory.  This is normally called once, when a
		///Directory gets this LockFactory instance.  However, you
		///can also call this (after this instance is assigned to
		///a Directory) to override the prefix in use.  This
		///is helpful if you're running Lucene on machines that
		///have different mount points for the same shared
		///directory.
		/// </summary>
		public virtual string LockPrefix
		{
			get
			{
				return _lockPrefix;
			}
			set
			{
				_lockPrefix = value;
			}
		}

		///<summary>
		///Return a new Lock instance identified by lockName.
		///<param name="lockName">name of the lock to be created.</param>
		///</summary>
		public abstract ILock MakeLock(string lockName);

		///<summary>
		/// Attempt to clear (forcefully unlock and remove) the
		/// specified lock.  Only call this at a time when you are
		/// certain this lock is no longer in use.
		/// <param name="lockName">name of the lock to be cleared.</param>
		/// </summary>
		public abstract void ClearLock(string lockName);
	}
}